

jQuery(function ($) {
    var user = JSON.parse(localStorage.getItem('user_info')) || {};
    var keyWord = window.location.pathname.split('-')[1].split('.')[0];
    if(user){
       var id = user.id;
       var token = user.token; 
    }else{
        var token = '';     
    }
    
    if (!keyWord) {
        return;
    }
    
    $.ajax({
        type: "get",
        url: host + "/api/artist/catArtistList?mostCount=" + 20+'&isNeesOthers=1',
        contentType: "application/json",
        xhrFields: {
            withCredentials: true
        },
        beforeSend: function beforeSend(request) {
            request.setRequestHeader("X-AUTH-TOKEN", token);
        },
        success: function success(data) {
            if (data.code == 200 && data.data) {
                var html = "";
                var dataCatArtistList = data.data.catArtistList;
                // $('.brand_cate_list h2').attr('class', dataCat.url);
                $('.brand_cate_list h2').html( '全部供应商');
                //艺术家分类
                for (var i = 0; i < dataCatArtistList.length; i++) {
                    html += '  <li>\n                            <a href="/mj/zuozhe-' + dataCatArtistList[i].id + '/" target="_blank"><img src="' + (dataCatArtistList[i].portrait ? isImgHttp(dataCatArtistList[i].portrait) : '/asset/image/head.png') + '" alt=""></a>\n                            <p><span>' + dataCatArtistList[i].name + '</span></p>\n                            <p>' + (dataCatArtistList[i].professional_title ? dataCatArtistList[i].professional_title.split('，')[0] : '') + '</p>\n                        </li>\n                    ';
                };
                $('.artist_list').html(html);
            } else {
                alert('网络加载失败，请稍候再试!');
            }
        },
        error: function error(_error) {
            //请求失败的回调方法 
            alert('网络加载失败，请稍候再试!');
        }
    });
});